<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>函数求阶乘</title>
</head>
<body>
    <script>
        var n = prompt('求n的阶乘：');
    function getC(n){
        if(n==1){
            return 1;
        }
        return n*getC(n-1);
    }    
    var getSum=0;
        for(var i=1;i<=n;i++){
            getSum+=getC(i);

        }
    
    document.write(n+ '的阶乘是:' + getC(n)+'<br/>');
    document.write(n+ '的阶乘累加和是:' + getSum);
    </script>
</body>
</html>